package aes

import (
	"encoding/base64"
	"github.com/wumansgy/goEncrypt/aes"
)

var aesSecretKey = []byte("tu3c5t81v3wt1o8j")
var ivAes = []byte("1c5t86wt1o8c5t8z")

func AesCbcEncryptBase64(data string) (cipherTextBase64 string, err error) {
	encryBytes, err := aes.AesCbcEncrypt([]byte(data), aesSecretKey, ivAes)
	return base64.StdEncoding.EncodeToString(encryBytes), err
}

func AesCbcDecryptByBase64(cipherTextBase64 string) (plainText []byte, err error) {
	plainTextBytes, err := base64.StdEncoding.DecodeString(cipherTextBase64)
	if err != nil {
		return []byte{}, err
	}
	return aes.AesCbcDecrypt(plainTextBytes, aesSecretKey, ivAes)
}
